package com.xinhua.erp.controller;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.pojo.Resale;
import com.xinhua.erp.service.ResaleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("resale")
public class ResaleController {
    @Autowired
    private ResaleService resaleService;


    @GetMapping("{id}")
    public Result findById(@PathVariable long id) {
        return resaleService.findById(id);
    }

    @GetMapping("{type}/{page}/{size}")
    public Result findAll(@PathVariable String type,@PathVariable int page, @PathVariable int size) {
        return resaleService.findAll(type,page, size);
    }

    @DeleteMapping("{id}")
    public Result deleteById(@PathVariable long id) {
        return resaleService.deleteById(id);
    }

    @PostMapping
    public Result save(@RequestBody Resale resale) {
        return resaleService.save(resale);
    }

    @PutMapping("{id}")
    public Result update(@PathVariable Long id,@RequestBody Resale resale) {
        return resaleService.update(id,resale);
    }
    @PostMapping("search/{page}/{size}")
    public Result Search(@RequestBody Map searchMap, @PathVariable int page, @PathVariable int size){
        return resaleService.Search(searchMap,page,size);
    }

//    @PutMapping("state/{id}")
//    public Result updateState(@PathVariable Long id){
//        return resaleService.updateState(id);
//    }
}
